{extend name="layout" /}
{block name="content"}
<div class="layui-form" lay-filter="LAY-set-wechat-menu-form" id="LAY-set-wechat-menu-form"
     style="padding-top: 30px; ">
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" lay-verify="required" placeholder="请输入..." autocomplete="off"
                   class="layui-input" value="{$menu.name|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单内容</label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="click" title="发送消息" {if !$menu || $menu && $menu['type']=="click"}checked=""{/if} lay-filter="type">
            <input type="radio" name="type" value="view" title="跳转网页" {if $menu && $menu['type']=="view"}checked=""{/if} lay-filter="type">
            <input type="radio" name="type" value="miniprogram" title="跳转小程序" {if $menu && $menu['type']=="miniprogram"}checked=""{/if} lay-filter="type">
        </div>
    </div>

    <div class="layui-form-item type view" style="display: none">
        <label class="layui-form-label">页面地址</label>
        <div class="layui-input-block">
            <input type="text" name="url"
                   value="{$menu.url|default=''}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item type miniprogram" style="display: none">
        <label class="layui-form-label">小程序appid</label>
        <div class="layui-input-inline">
            <input type="text" name="appid"
                   value="{$menu.appid|default=''}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item type miniprogram" style="display: none">
        <label class="layui-form-label">小程序路径</label>
        <div class="layui-input-block">
            <input type="text" name="pagepath"
                   value="{$menu.pagepath|default=''}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-set-wechat-menu-submit" id="LAY-set-wechat-menu-submit"
               value="确认">
    </div>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['index', 'form'], function () {
        var $ = layui.$
            , form = layui.form;

        $(".{$menu.type|default='click'}").show();
        form.on('radio(type)', function (data) {
            $('.type').hide();
            $('.' + data.value).show();
        });
    })
</script>
{/block}